#include "soundbuffer.h"

SoundBuffer::SoundBuffer(size_t size, QObject *parent)
	: QObject(parent), _capacity(size)
{
	_index = 0;
	for (size_t i = 0; i < _capacity; i++)
		_buffer.push_back(new SoundPacket);
}

SoundBuffer::~SoundBuffer()
{
	for (size_t i = 0; i < _capacity; i++)
		delete _buffer[i];
}

SoundPacket						*SoundBuffer::get()
{
	SoundPacket					*ret = _buffer[_index];

	_index++;
	_index = _index % _capacity;
	return ret;
}